<%@ page contentType="text/html;charset=UTF-8"%>

<ul id="tt" class="easyui-tree"></ul>

<script>
    $('#tt').tree({
        //url:'tree_data.json'
        animate: true,
        data:[{
            "id": 1,
            "icon": "fa-home",
            "text": "xxx",
            "url": "#",
            "state": "closed",
            "children": [{
                "id": 11,
                "url": "/sys/function",
                "text": "Node 11"
            },{
                "id": 12,
                "url": "/sys/role",
                "text": "Node 12"
            },{
                "id": 13,
                "url": "/sys/role",
                "text": "Node 12"
            },{
                "id": 14,
                "url": "/sys/role",
                "text": "Node 12"
            },{
                "id": 15,
                "url": "/sys/role",
                "text": "Node 12"
            },{
                "id": 16,
                "url": "/sys/role",
                "text": "Node 12"
            }]
        },{
            "id": 2,
            "icon": "fa-home",
            "text": "xxx",
            "url": "#",
            "state": "closed"
        },{
            "id": 3,
            "icon": "fa-home",
            "text": "xxx",
            "url": "#",
            "state": "closed"
        },{
            "id": 4,
            "icon": "fa-home",
            "text": "xxx",
            "url": "#",
            "state": "closed"
        }],
        onClick: function(node){
            if($(this).tree('isLeaf',node.target)) {
                $AzerothData.methods.addTabs(node.text, node.url, node.id);
                return false;
            }

            $(this).tree('collapseAll');
            if(node.state=="open") {
                return false;
            }
            $(this).tree('expand',node.target);
        },
        formatter:function(node){
            if(node.icon==null) {
                return "<a class='treespan treespan-second'>"+node.text+"</a>";
            }
            return "<i class='fa "+node.icon+"'></i><a class='treespan'>"+node.text+"</a>";
        }

    });

</script>